home *** CD-ROM | disk | FTP | other *** search
- program TestSrch;
-
- {$IFNDEF Win32}
- !! Sorry, this program can only be compiled in 32-bits
- {$ENDIF}
-
- {$APPTYPE CONSOLE}
-
- uses
- Windows,
- SysUtils,
- BMSearch in 'BMSearch.pas';
-
- var
- TextBlock : string;
-
- procedure FindWithPos(aWord : string);
- var
- PosWord : integer;
- StartTime : integer;
- i : integer;
- begin
- writeln('Searching for [', aWord, '] with Pos');
- StartTime := GetTickCount;
- for i := 1 to 5000 do
- PosWord := Pos(aWord, TextBlock);
- writeln(GetTickCount - StartTime);
- end;
-
- procedure FindWithBMPos(aWord : string);
- var
- PosWord : integer;
- StartTime : integer;
- i : integer;
- begin
- writeln('Searching for [', aWord, '] with Boyer-Moore Pos');
- StartTime := GetTickCount;
- for i := 1 to 5000 do
- PosWord := BMPosSimple(aWord, TextBlock);
- writeln(GetTickCount - StartTime);
- end;
-
- procedure FindWithBMPosEx(aWord : string);
- var
- PosWord : integer;
- StartTime : integer;
- i : integer;
- begin
- writeln('Searching for [', aWord, '] with Boyer-Moore Pos');
- StartTime := GetTickCount;
- for i := 1 to 5000 do
- PosWord := BMPos(aWord, TextBlock, true, 1);
- writeln(GetTickCount - StartTime);
- end;
-
- var
- FSize : integer;
- F : file;
-
- begin
- Assign(F, 'LLL.TXT');
- Reset(F, 1);
- FSize := FileSize(F);
- SetLength(TextBlock, FSize);
- BlockRead(F, TextBlock[1], FSize);
- Close(F);
-
- writeln(Pos('keel', TextBlock));
- writeln(BMPosSimple('keel', TextBlock));
- writeln(BMPos('KEEL', TextBlock, true, 1));
- writeln(Pos('keep', TextBlock));
- writeln(BMPosSimple('keep', TextBlock));
- writeln(BMPos('KEEP', TextBlock, true, 1));
- writeln(Pos('keek', TextBlock));
- writeln(BMPosSimple('keek', TextBlock));
- writeln(BMPos('KEEK', TextBlock, true, 1));
- writeln(Pos('tongues of mocking wenches', TextBlock));
- writeln(BMPosSimple('tongues of mocking wenches', TextBlock));
- writeln(BMPos('TONGUES OF MOCKING WENCHES', TextBlock, true, 1));
-
- FindWithPos('keel');
- FindWithBMPos('keel');
- FindWithPos('keep');
- FindWithBMPos('keep');
- FindWithPos('keek');
- FindWithBMPos('keek');
- FindWithPos(' keel');
- FindWithBMPos(' keel');
- FindWithPos(' keep');
- FindWithBMPos(' keep');
- FindWithPos(' keek');
- FindWithBMPos(' keek');
-
- FindWithPos('tongues of mocking wenches');
- FindWithBMPos('tongues of mocking wenches');
- FindWithBMPosEx('TONGUES OF MOCKING WENCHES');
-
- readln;
- end.
-
-